<template>
<div>
  <el-form :inline="true">
    <el-form-item>
      <el-button type="primary" @click="exportExcel">导出</el-button>
    </el-form-item>
  </el-form>
  <BrowseDataList2 :cols="cols" :fetchData="fetchData" />
</div>
</template>
<script>
import BrowseDataList2 from "@/components/BrowseDataList2";
import { getCheckList } from "@/api/权限";
import { getUser } from "@/utils/auth";
import linq from "linq"
import { Promise } from 'q';
export default {
  components: {
    BrowseDataList2
  },
  data() {
    return {
      datas:[],
      cols: [
        {label:"目录名称",prop:"目录名称"},
       
        { label: "字段名", prop: "字段名" },
        { label: "内容", prop: "内容" },
          { label: "出错原因", prop: "出错原因" }
      ]
    };
  },
   
  methods: {
 exportExcel() {
      var XLSX = require("xlsx");
     
      var ws = XLSX.utils.json_to_sheet(this.datas);
      var wb = XLSX.utils.book_new(); /*新建book*/
      XLSX.utils.book_append_sheet(
        wb,
        ws,
        "数据检测"
      ); /* 生成xlsx文件(book,sheet数据,sheet命名) */
      XLSX.writeFile(wb, "数据检测.xlsx"); /*写文件(book,xlsx文件名称)*/
    },
   fetchData() {
      return new Promise(async (resolve,reject)=>{
           var user = getUser();
        var datas = await getCheckList(user.XXID, user.CJPC);
       this.datas = datas;
        resolve(datas);
      });
    }
  }
};
</script>
<style>
</style>